﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Runtime.Caching;

namespace NFL.Core
{
    public class CacheItems
    {

        // Private variables
        private static ObjectCache cache = MemoryCache.Default;

        // Public methods
        public static Object GetCachedItem(Enums.CacheItems item)
        {
            Object returnObject = null;
            if (cache.Contains(item.ToString()))
            {
                returnObject = cache[item.ToString()] as Object;
            }
            return returnObject;
        }

        public static void SetCachedItem(Enums.CacheItems item, Object val)
        {
            cache[item.ToString()] = val;
        }

        public static void SetCachedItem(Enums.CacheItems item, Object val, int expireMinutes)
        {
            CacheItemPolicy cip = new CacheItemPolicy();
            cip.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(expireMinutes);
            cache.Add(item.ToString(), val, cip);
        }

    }
}
